home *** CD-ROM | disk | FTP | other *** search
- package sub_arctic.input;
- import sub_arctic.lib.interactor;
- import sub_arctic.lib.sub_arctic_error;
-
- /**
- * This is the class that handles dispatching the work_procs on
- * the "synchronized side of the world."<P>
- *
- * User's should never use this class directly but should use
- * the API in the manager instead.
- *
- * @author Ian Smith
- */
- public class work_agent extends dispatch_agent {
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * We derive our event code in the same way the animation agent
- * does, by guessing! See the animation_agent code for more
- * on why this is...
- */
- public static final int WORK_EVENT = 1000 + 11;
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Indicate whether the given event might be dispatchable by this
- * agent. Events will not be delivered to the agent unless they pass this
- * test. We only accept the work event.
- *
- * @param event evt the event to be tested for usefulness.
- * @return boolean true if the event is one this agent is interested in.
- */
- public boolean event_is_useful(event evt) {
- return (evt.id()==WORK_EVENT);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Dispatch a work event.
- *
- * @param event evt the event to dispatch.
- * @param Object user_info policy defined user information
- * @param interactor to_obj the object to (possibly)send the event to
- * @param int seq_num the sequence number of this event
- */
- public boolean dispatch_event(event evt, Object user_info,
- interactor to_obj, int seq_num) {
- Object arg;
- work_pair pair;
- work_proc proc;
-
- /* extract what the manager gave us */
- arg=evt.arg();
- if (arg instanceof work_pair == false) {
- throw new sub_arctic_error("work_agent: Serious problem: unknown "+
- "argument type inside a work event!");
- }
-
- /* extract the prog and the arg */
- pair = (work_pair) arg;
- proc = pair.proc();
- arg=pair.obj();
-
- /* dispatch the closure */
- proc.run_safely(arg);
-
- /* we are done! */
- return true;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- }
- /*=========================== COPYRIGHT NOTICE ===========================
-
- This file is part of the subArctic user interface toolkit.
-
- Copyright (c) 1996 Scott Hudson and Ian Smith
- All rights reserved.
-
- The subArctic system is freely available for most uses under the terms
- and conditions described in
- http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html
- and appearing in full in the lib/interactor.java source file.
-
- The current release and additional information about this software can be
- found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
-
- ========================================================================*/
-